<template>
  <div>
    <el-form ref="form" :rules="rules" :model="form" label-width="300px">
      <el-form-item label="商场名称" prop="litemall_mall_name">
        <el-input v-model="form.litemall_mall_name" size="mini"></el-input>
      </el-form-item>
      <el-form-item label="商场地址" prop="litemall_mall_address">
        <el-input v-model="form.litemall_mall_address" size="mini"></el-input>
      </el-form-item>
      <el-form-item label="地理坐标">
        <el-col :span="11">
          <el-input
            size="mini"
            placeholder="经度"
            v-model="form.litemall_mall_longitude"
            style="width: 100%"
          ></el-input>
        </el-col>
        <el-col class="line" style="text-align: center" :span="2"> -</el-col>
        <el-col :span="11">
          <el-input
            size="mini"
            placeholder="纬度"
            v-model="form.litemall_mall_latitude"
            style="width: 100%"
          ></el-input>
        </el-col>
      </el-form-item>
      <el-form-item label="联系电话" prop="litemall_mall_phone">
        <el-input v-model="form.litemall_mall_phone" size="mini"></el-input>
      </el-form-item>
      <el-form-item label="联系QQ" prop="litemall_mall_qq">
        <el-input v-model="form.litemall_mall_qq" size="mini"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="nono('form')" size="mini">取消</el-button>
        <el-button type="primary" @click="updates('form')" size="mini"
          >确定</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getList, update } from "@/api/configuration/shopping";
export default {
  data() {
    return {
      form: {},
      rules: {
          litemall_mall_name: [{required: true, message: '不能为空', trigger: 'blur'}],
          litemall_mall_address:[{required: true, message: '不能为空', trigger: 'blur'}],
          litemall_mall_phone:[{required: true, message: '不能为空', trigger: 'blur'}],
          litemall_mall_qq:[{required: true, message: '不能为空', trigger: 'blur'}]

        }
    };
  },
  created() {
    this.getdata();
  },
  methods: {
    getdata() {
      getList().then((res) => {
        console.log(res);
        this.form = res.data;
      });
    },
    updates(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          update(this.form).then((res) => {
            console.log(res);
            this.$notify({
              title: "成功",
              message: "商场配置成功",
              type: "success",
            });
          });
        }
      });
    },
    //取消
    nono(formName){
      this.$refs[formName].resetFields();
      this.getdata();
    }
  },
};
</script>

<style lang="scss" scoped>
</style>